<div class="modal-dialog" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">用户信息</h4>
        </div>
        <form style="padding:4%;height:410px;overflow-y:auto;" id="addTeamForm" data-toggle="validator" role="form">
            <input type="hidden" value="{$user.id}" name="userId" />
        	<div class="row">
        		<div class="form-group col-sm-6">
	                <label class="control-label">姓名<span style="color:red;">*</span></label>
	                <input type="text" class="form-control" name="real_name"  value="{$user.real_name}" placeholder="请填写姓名" data-error="姓名为必填项!" required>
        		</div>
        		<div class="form-group col-sm-6">
	                <label class="control-label">身份证号</label>
	                <input type="text" class="form-control" name="identity"  value="{$user.identity}" placeholder="请填写身份证号"  >
                        <div class="help-block with-errors"></div>
        		</div>
        		<div class="form-group col-sm-6">
	                <label class="control-label">手机号<span style="color:red;">*</span></label>
	                <input type="tel" class="form-control" name="mobile"  value="{$user.mobile}" placeholder="请填写手机号" data-error="手机号为必填项!" required>

        		</div>
        		<div class="form-group col-sm-6">
	                <label class="control-label">邮箱</label>
	                <input type="text" class="form-control" name="email"  value="{$user.email}" placeholder="请填写邮箱">
        		</div>
        		<div class="form-group col-sm-6">
	                <label class="control-label">职务</label>
	                <input type="text" class="form-control" name="position"  value="{$user.position}" placeholder="请填写职务">
        		</div>
				<div class="form-group col-sm-6">
					<label class="control-label">用户角色</label>
					<select name="role_id" class="form-control">
						<volist name="roleList" id="role">
							<option <if condition="$user['role_id'] eq $role['id']">selected="selected"</if> value="{$role.id}">{$role.name}</option>
						</volist>
					</select>
				</div>
				<div class="form-group col-sm-6">
					<label class="control-label">所属团队</label>
					<select class="form-control" name="team_id" id="team_id">
						<option value="" <if condition="$user['team_id'] eq ''">selected</if>>不限</option>
						<foreach name="teams" item="team">
							<option value="{$team.id}" <if condition="$user['team_id'] eq $team['id']">selected</if>>{$team.team_name}</option>
						</foreach>
					</select>
				</div>
        		<div class="form-group col-sm-12">
	                <label class="control-label">备注</label>
                        <textarea rows="4" class="form-control" name="{$user.remark}" cols="200" placeholder="200字以内"></textarea>
        		</div>
        	</div>
        </form>
        <div class="modal-footer">
            <button type="button" data-dismiss="modal" class="btn btn-default">取消</button>
            <button type="button" id="saveTeam" class="btn btn-primary">保存</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="__PUBLIC__/js/select2/select2.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/validator.min.js"></script>
<script>
    
   $("#addTeamForm").validator();

    var saveUrl = "{$saveUrl}";
    $("#saveTeam").click(function () {
        var validator = $("#addTeamForm").data("bs.validator");
        validator.validate();
        if(!validator.hasErrors()){
            $.ajax({
                url: saveUrl,
                type: "post",
                dataType: "json",
                data: $("#addTeamForm").serialize(),
                success: function (data) {
                    if(data.status){
                        $("#commonModal").modal('toggle');
                        common.alert("提示", data.msg, function () {
                            common.reload();
                        });
                    }else{
                        common.alert("提示", data.msg);
                    }
                }
            })
        }
    })
    
</script>